//=============================================================================
// CeilingSentinel - Latches on to the ceiling and shoots at things.
//=============================================================================
class CeilingSentinel extends Sentinel
	placeable;

var SentinelBase CannonBase;

simulated function PostBeginPlay()
{
	Super.PostBeginPlay();

	if(Level.NetMode != NM_DedicatedServer)
	{
		CannonBase = Spawn(class'SentinelBase');
		CannonBase.SetBase(self);
	}
}

simulated function RotateCannon()
{
	local rotator PitchBoneRot, YawBoneRot;

	YawBoneRot.Yaw = CurrentAim.Roll;
	PitchBoneRot.Yaw = CurrentAim.Yaw;
	SetRotation(YawBoneRot);
	SetBoneRotation('Bone_pivot02', PitchBoneRot, 0, 1);
}

function JumpOffPawn(){}

simulated event Destroyed()
{
    local int i,upgrade_limits;
    local float lcost;
    local string leftS, rightS;

    upgrade_limits = 9;
    i=0;
    if(self.PlayerReplicationInfo!=none)
        myteam=self.PlayerReplicationInfo.Team.TeamIndex;

    if(Upgrade != None)
    {
        while(i<upgrade_limits)
        {
        if(CheckUpgrades(class 'TFMenuConsole'.default.SentinelUpgrade[i])==true)
            {
	        divide(class 'TFMenuConsole'.default.SentinelUOption[i]," ",lefts,rightS);
            if(lefts=="") lcost=0;
            else lcost=float(lefts);
	        if(level.game != none) tfgri(level.game.gamereplicationinfo).control[myteam]-=lcost;
            }
         i++;
        }
   	}

	if(CannonBase != None)
		CannonBase.Destroy();

	Super.Destroyed();
}

simulated function bool AllowUpgrade(class<SentinelUpgrade> NewUpgradeClass, pawn user, optional float cost)
{
	if(!NewUpgradeClass.Default.bFitsCeiling)
		return false;

	return Super.AllowUpgrade(NewUpgradeClass,user,cost);
}

defaultproperties
{
    maxPitch=4096.000000
    MinPitch=-12288.000000
    AimAhead=0.900000
    MaxAimError=1024.000000
    SensorAngle=143.000000
    ShadowDir=(Z=-3.000000)
    TeamMarkerOffset=(Z=-20.000000)
    DefaultWeaponClass=Class'taskforces.SentinelPulseSmall'
    DefaultWeap="taskforces.SentinelPulseSmall"
    HearingThreshold=5000.000000
    SightRadius=9000.000000
    PeripheralVision=-0.800000
    BaseEyeHeight=-8.000000
    EyeHeight=-8.000000
    Mesh=SkeletalMesh'Cannons.CielingCannon'
    PrePivot=(Z=24.000000)
    Skins(0)=Shader'TFMedia.Cannons.CeilingCannonShader'
    CollisionRadius=40.000000
    CollisionHeight=24.000000
    bHardAttach=True
    Mass=100.000000
	Physics=PHYS_None
	Sname="Turret Sentinel"
	refControl=200
}
